
$file1 = "/data1/bsi/bioinf_int/s106381.borawork/data_HTHGU/MayoGAP/mayogap_emerge/Mapping250K_Nsp.na30.txt";
$file2 = "/data1/bsi/bioinf_int/s106381.borawork/data_HTHGU/MayoGAP/mayogap_emerge/Mapping250K_Sty.na30.txt";
#$file5 = "/data1/bsi/bioinf_int/s106381.borawork/data_HTHGU/MayoGAP/mayogap_emerge/GenomeWideSNP_5.na30.txt";
$file3 = "/data1/bsi/bioinf_int/s106381.borawork/data_HTHGU/MayoGAP/mayogap_emerge/raw/new_mayogap_emerge_raw.tped";
#$file4 = "/data1/bsi/bioinf_int/s106381.borawork/data_HTHGU/MayoGAP/mayogap_emerge/clean/new_mayogap_emerge_clean.map";
#open(BUFF1,$file1);
#open(BUFF2,$file2);
open(BUFF3,$file3);
#open(BUFF5,$file5);
#open(BUFF4,$file4);
open(WRBUFF,">/data1/bsi/bioinf_int/s106381.borawork/data_HTHGU/MayoGAP/mayogap_emerge/emerge_checkstard_500k.txt");
$line = <BUFF1>;
$line = <BUFF2>;
#$n = 4;
#$line = <BUFF5>;


while($line= <BUFF3>)
{
        chomp $line;
        $line =~ s/\n//g;
        $line =~ s/\r//g;
	@array = split(" ",$line);
#	print $array[1]."\n";
#	$file = "/data1/bsi/bioinf_int/s106381.borawork/data_HTHGU/MayoGAP/mayogap_emerge/output.txt";
#	system("cut -d ' ' -f$n /data1/bsi/bioinf_int/s106381.borawork/data_HTHGU/MayoGAP/mayogap_emerge/clean/new_mayogap_emerge_clean.ped |head -20 >$file");
#$com = "head -20 $file3|cut -d ' ' -f$n  >$file";
#print $com."\n";
#system("$com");
#system("head -20 $file3|cut -d ' ' -f$n  >$file");
#	system("head -40 /data1/bsi/bioinf_int/s106381.borawork/data_HTHGU/MayoGAP/mayogap_emerge/clean/new_mayogap_emerge_clean.ped |cut -d ' ' -f$n   >$file");
#	open(BUFF,$file);
#	@liney = <BUFF>;
	$conc = $array[4];
	for($i=5;$i<20;$i++)
	{
		$conc = $conc."_".$array[$i];

	}
	chomp $array[1];
	$array[1] =~ s/\n//g;
	$array[1] =~ s/\t//g;
	$array[1] =~ s/\r//g;
	$array[1] =~ s/\s//g;
$hash{$array[1]} = $conc;
#	$hash{$array[1]} = join("_",@liney);
#	print $hash{$array[1]}."\n";
	$hash{$array[1]} =~ s/\n//g;
#	print $hash{$array[1]}."\n";
#	$n++;
#	close BUFF;	


}
=head
while($line= <BUFF5>)
{
        chomp $line;
        $line =~ s/\n//g;
        $line =~ s/\r//g;
        @array = split("\t",$line);
         $array[1] =~ s/\n//g;
        $array[1] =~ s/\t//g;
        $array[1] =~ s/\r//g;

        print WRBUFF $array[1]."\t".$array[2]."\t".$array[3]."\t".$array[4]."\t".$array[8]."\t".$array[9]."\t".$hash{$array[1]}."\n";

}

=cut
while($line= <BUFF1>)
{
	chomp $line;
	$line =~ s/\n//g;
	$line =~ s/\r//g;
	@array = split("\t",$line);
	 $array[1] =~ s/\n//g;
        $array[1] =~ s/\t//g;
        $array[1] =~ s/\r//g;
	$array[1] =~ s/\s//g;
	print WRBUFF $array[1]."\t".$array[2]."\t".$array[3]."\t".$array[4]."\t".$array[8]."\t".$array[9]."\t".$hash{$array[1]}."\n";

}
while($line= <BUFF2>)
{
        chomp $line;
	 $array[1] =~ s/\n//g;
        $array[1] =~ s/\t//g;
        $array[1] =~ s/\r//g;
	$array[1] =~ s/\s//g;
        $line =~ s/\n//g;
        $line =~ s/\r//g;
        @array = split("\t",$line);
        print WRBUFF $array[1]."\t".$array[2]."\t".$array[3]."\t".$array[4]."\t".$array[8]."\t".$array[9]."\t".$hash{$array[1]}."\n";

}

